#ifndef _NGX_NGIM_CURL_H_INCLUDED_
#define _NGX_NGIM_CURL_H_INCLUDED_

#include "ngx_ngim.h"
#include "ngx_ngim_http_module.h"


typedef enum {
  easyinfo_init=0, 
  easyinfo_running, 
  easyinfo_remove_sock, 
  easyinfo_done, 
  easyinfo_reset, 
  easyinfo_cleanuped 
} ngi_ngim_easyinfo_stat_t;

/* Information associated with a specific easy handle */
typedef struct ngx_ngim_easyinfo_s
{
  CURL 		        *easy;
  ngx_ngim_session_t    *session;
  u_char                  *url;
  ngx_int_t                idx;
  ngx_int_t                code;
  u_char                   error[CURL_ERROR_SIZE];
  ngx_str_t                content;
  ngx_uint_t               left;
  double                   download_content_len;
  ngi_ngim_easyinfo_stat_t stat; 
} ngx_ngim_easyinfo_t;


/* Information associated with a specific socket */
typedef struct ngx_ngim_easy_sockinfo_s
{
  curl_socket_t         sockfd;
  CURL                 *easy;
  int			action;
  //long 			timeout;
  int 			evset;
  ngx_connection_t     *connection;
  ngx_ngim_easyinfo_t  *curl_easyinfo;
} ngx_ngim_easy_sockinfo_t;

ngx_int_t ngx_ngim_curl_init(ngx_ngim_core_main_conf_t *m);
ngx_int_t ngx_ngim_curl_add_url(ngx_ngim_session_t *session,u_char *url , ngx_int_t idx);
ngx_int_t ngx_ngim_curl_cleanup_easyinfo(ngx_ngim_session_t  *s,ngx_array_t *easyinfoes);
ngx_int_t ngx_ngim_curl_destory(ngx_ngim_core_main_conf_t *m);

//ngx_int_t ngx_ngim_http_task_req_done(void *data);

#endif  //_NGX_NGIM_CURL_H_INCLUDED_
